package com.egao.common.manage.school;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.egao.common.component.elasticsearch.entity.vo.ElasticPushMsgFormVO;
import com.egao.common.core.annotation.OperLog;
import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.common.core.web.PageParam;
import com.egao.common.core.web.PageResult;
import com.egao.common.manage.StatisticsServiceImpl;
import com.egao.common.module.company.entity.vo.*;
import com.egao.common.module.company.service.*;
import com.egao.common.module.employment.entity.EmploymentProcess;
import com.egao.common.module.employment.service.EmploymentProcessService;
import com.egao.common.module.push.constants.PushConstants;
import com.egao.common.module.push.service.PushMsgService;
import com.egao.common.module.statistics.entity.EmploymentProcessStatisticsVO;
import com.egao.common.module.student.constants.StudentConstants;
import com.egao.common.module.student.entity.Student;
import com.egao.common.module.student.entity.StudentSign;
import com.egao.common.module.student.entity.StudentSignMajorRecord;
import com.egao.common.module.student.entity.StudentSignRecord;
import com.egao.common.module.student.entity.vo.StudentSignAlumniVO;
import com.egao.common.module.student.entity.vo.StudentSignStatistics;
import com.egao.common.module.student.entity.vo.StudentSignStatisticsCollegeVO;
import com.egao.common.module.student.service.*;
import com.egao.common.module.system.constants.DictConstants;
import com.egao.common.module.system.entity.College;
import com.egao.common.module.system.entity.Dict;
import com.egao.common.module.system.entity.User;
import com.egao.common.module.system.service.CollegeService;
import com.egao.common.module.system.service.DictService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;


/**
 * 学校数据统计管理
 *
 * @author dl
 */
@Api(tags = "学校数据统计管理")
@RestController
@RequestMapping("${api}")
public class SchoolStatisticsController extends BaseController {

    @Autowired
    private CompanyService companyService;
    @Autowired
    private RecruitService recruitService;
    @Autowired
    private PreachService preachService;
    @Autowired
    private PreachCloudService preachCloudService;
    @Autowired
    private MutualApplyService mutualApplyService;
    @Autowired
    private PushMsgService pushMsgService;
    @Autowired
    private CollegeService collegeService;
    @Autowired
    private DictService dictService;
    @Autowired
    private StudentSignService studentSignService;
    @Autowired
    private StatisticsServiceImpl statisticsService;
    @Autowired
    private StudentService studentService;
    @Autowired
    private StudentIntenService studentIntenService;
    @Autowired
    private EmploymentProcessService employmentProcessService;
    @Autowired
    private StudentSignRecordService studentSignRecordService;
    @Autowired
    private StudentSignMajorRecordService studentSignMajorRecordService;


    private static final String[] quarterEndDateArr = {"-03-31", "-06-30", "-09-30", "-12-31"};


    @PreAuthorize("hasAuthority('school:statistics:inten')")
    @ApiOperation("毕业意向统计")
    @GetMapping("/school/statistics/inten")
    public JsonResult inten(Integer year, String colleges) {
        return statisticsService.inten(year, colleges);
    }

    @PreAuthorize("hasAuthority('school:statistics:inten')")
    @ApiOperation("毕业意向-升学考公考研统计")
    @GetMapping("/school/statistics/inten-other")
    public JsonResult intenOther(Integer year, String colleges) {
        List<String> bjList = new ArrayList<>();
        if (!StrUtil.isBlank(colleges) && colleges.contains("b_")) {
            String[] collegeArr = colleges.split(",");
            for (String bjhm : collegeArr) {
                if (bjhm.contains("b_")) {
                    bjList.add(bjhm.split("b_")[1]);
                }
            }
            colleges = "";
        }

        List<String> collegeCodeList = new ArrayList<>();
        if (!StrUtil.isBlank(colleges)) {
            collegeCodeList = Arrays.stream(colleges.split(",")).collect(Collectors.toList());
        }
        List<Map<String, Object>> sx = studentIntenService.sxStatistics(year, collegeCodeList, bjList);
        List<Map<String, Object>> kg = studentIntenService.kgStatistics(year, collegeCodeList, bjList);
        List<Map<String, Object>> ky = studentIntenService.kyStatistics(year, collegeCodeList, bjList);
        List<Map<String, Object>> kyMajor = studentIntenService.kyMajorStatistics(year, collegeCodeList, bjList);
        List<Map<String, Object>> sxMajor = studentIntenService.sxMajorStatistics(year, collegeCodeList, bjList);
        return JsonResult.ok().put("sx", sx).put("kg", kg).put("ky", ky).put("kyMajor", kyMajor).put("sxMajor", sxMajor);
    }

    @PreAuthorize("hasAuthority('school:statistics:company')")
    @OperLog(value = "单位统计", desc = "统计查询")
    @ApiOperation(value = "单位统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "applyTime", value = "申请时间开始时间~申请时间结束时间 yyyy-MM-dd~yyyy-MM-dd，例：2021-3-10~2021-3-30", dataType = "String"),
            @ApiImplicitParam(name = "name", value = "单位名称", dataType = "String"),
            @ApiImplicitParam(name = "province", value = "所在省份", dataType = "String"),
            @ApiImplicitParam(name = "city", value = "所在城市", dataType = "String"),
            @ApiImplicitParam(name = "nature", value = "单位性质字典值", dataType = "String"),
            @ApiImplicitParam(name = "industry", value = "单位行业字典值", dataType = "String"),
            @ApiImplicitParam(name = "scale", value = "单位规模字典值", dataType = "String"),
    })
    @ApiResponses({
            @ApiResponse(code = 1, message = "查询成功（total：总数，省份：provinceList，性质：natureList，行业：industryList，规模：scaleList")
    })
    @GetMapping("/school/statistics/company")
    public JsonResult countCompany(HttpServletRequest request) {
        PageParam<CompanyListVO> pageParam = new PageParam<>(request);
        return companyService.countCompany(pageParam);
    }

    @PreAuthorize("hasAuthority('school:statistics:recruit')")
    @OperLog(value = "招聘信息发布统计", desc = "统计查询")
    @ApiOperation(value = "招聘信息发布统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "applyTime", value = "申请时间开始时间~申请时间结束时间 yyyy-MM-dd~yyyy-MM-dd，例：2021-3-10~2021-3-30", dataType = "String"),
            @ApiImplicitParam(name = "title", value = "标题", dataType = "String"),
            @ApiImplicitParam(name = "addType", value = "发布类型（1：单位/2：学校", dataType = "String"),
            @ApiImplicitParam(name = "type", value = "招聘类型（1：在线招聘 2：实习信息）", dataType = "String"),
            @ApiImplicitParam(name = "majors", value = "相关专业（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "jobs", value = "岗位名称（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "education", value = "岗位学历（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "jobCategory", value = "岗位类型（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "province", value = "所在省份", dataType = "String"),
            @ApiImplicitParam(name = "city", value = "所在城市", dataType = "String"),
            @ApiImplicitParam(name = "nature", value = "单位性质字典值", dataType = "String"),
            @ApiImplicitParam(name = "industry", value = "单位行业字典值", dataType = "String"),
            @ApiImplicitParam(name = "scale", value = "单位规模字典值", dataType = "String"),
    })
    @ApiResponses({
            @ApiResponse(code = 1, message = "查询成功（total：总数，发布类型：addTypeList，岗位类型：jobCategoryList，行业：educationList，省份：provinceList，性质：natureList，行业：industryList，规模：scaleList")
    })
    @GetMapping("/school/statistics/recruit")
    public JsonResult countRecruit(HttpServletRequest request) {
        PageParam<RecruitListVO> pageParam = new PageParam<>(request);
        return recruitService.countRecruit(pageParam);
    }

    @PreAuthorize("hasAuthority('school:statistics:recruit')")
    @OperLog(value = "招聘信息发布统计岗位类型", desc = "统计查询")
    @ApiOperation(value = "招聘信息发布统计岗位类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "applyTime", value = "申请时间开始时间~申请时间结束时间 yyyy-MM-dd~yyyy-MM-dd，例：2021-3-10~2021-3-30", dataType = "String"),
            @ApiImplicitParam(name = "title", value = "标题", dataType = "String"),
            @ApiImplicitParam(name = "addType", value = "发布类型（1：单位/2：学校", dataType = "String"),
            @ApiImplicitParam(name = "type", value = "招聘类型（1：在线招聘 2：实习信息）", dataType = "String"),
            @ApiImplicitParam(name = "majors", value = "相关专业（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "jobs", value = "岗位名称（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "education", value = "岗位学历（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "jobCategory", value = "岗位类型（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "province", value = "所在省份", dataType = "String"),
            @ApiImplicitParam(name = "city", value = "所在城市", dataType = "String"),
            @ApiImplicitParam(name = "nature", value = "单位性质字典值", dataType = "String"),
            @ApiImplicitParam(name = "industry", value = "单位行业字典值", dataType = "String"),
            @ApiImplicitParam(name = "scale", value = "单位规模字典值", dataType = "String"),
    })
    @ApiResponses({
            @ApiResponse(code = 1, message = "查询成功（total：总数，发布类型：addTypeList，岗位类型：jobCategoryList，行业：educationList，省份：provinceList，性质：natureList，行业：industryList，规模：scaleList")
    })
    @GetMapping("/school/statistics/recruit-category")
    public JsonResult countRecruitCategory(HttpServletRequest request) {
        PageParam<RecruitListVO> pageParam = new PageParam<>(request);
        return recruitService.countRecruitCategory(pageParam);
    }


    @PreAuthorize("hasAuthority('school:statistics:recruit')")
    @OperLog(value = "招聘信息发布统计学历", desc = "统计查询")
    @ApiOperation(value = "招聘信息发布统计学历")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "applyTime", value = "申请时间开始时间~申请时间结束时间 yyyy-MM-dd~yyyy-MM-dd，例：2021-3-10~2021-3-30", dataType = "String"),
            @ApiImplicitParam(name = "title", value = "标题", dataType = "String"),
            @ApiImplicitParam(name = "addType", value = "发布类型（1：单位/2：学校", dataType = "String"),
            @ApiImplicitParam(name = "type", value = "招聘类型（1：在线招聘 2：实习信息）", dataType = "String"),
            @ApiImplicitParam(name = "majors", value = "相关专业（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "jobs", value = "岗位名称（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "education", value = "岗位学历（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "jobCategory", value = "岗位类型（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "province", value = "所在省份", dataType = "String"),
            @ApiImplicitParam(name = "city", value = "所在城市", dataType = "String"),
            @ApiImplicitParam(name = "nature", value = "单位性质字典值", dataType = "String"),
            @ApiImplicitParam(name = "industry", value = "单位行业字典值", dataType = "String"),
            @ApiImplicitParam(name = "scale", value = "单位规模字典值", dataType = "String"),
    })
    @ApiResponses({
            @ApiResponse(code = 1, message = "查询成功（total：总数，发布类型：addTypeList，岗位类型：jobCategoryList，行业：educationList，省份：provinceList，性质：natureList，行业：industryList，规模：scaleList")
    })
    @GetMapping("/school/statistics/recruit-education")
    public JsonResult countRecruitEducation(HttpServletRequest request) {
        PageParam<RecruitListVO> pageParam = new PageParam<>(request);
        return recruitService.countRecruitEducation(pageParam);
    }

    @PreAuthorize("hasAuthority('school:statistics:preach')")
    @OperLog(value = "校内宣讲会发布统计", desc = "统计查询")
    @ApiOperation(value = "校内宣讲会发布统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "applyTime", value = "举办时间开始时间~举办时间结束时间 yyyy-MM-dd~yyyy-MM-dd，例：2021-3-10~2021-3-30", dataType = "String"),
            @ApiImplicitParam(name = "title", value = "标题", dataType = "String"),
            @ApiImplicitParam(name = "fieldName", value = "举办场地", dataType = "String"),
            @ApiImplicitParam(name = "companyName", value = "主办方", dataType = "String"),
            @ApiImplicitParam(name = "invalid", value = "是否取消（1：已取消 0：未取消）", dataType = "String"),
            @ApiImplicitParam(name = "state", value = "审核状态（0：待审核 1：审核通过 2：审核不通过）", dataType = "String"),
            @ApiImplicitParam(name = "paramType", value = "查询类型（and：并且 or：或者）", dataType = "String"),
            @ApiImplicitParam(name = "majors", value = "相关专业（可以,分隔）", dataType = "String"),
            @ApiImplicitParam(name = "jobs", value = "岗位名称（可以,分隔）", dataType = "String"),

            @ApiImplicitParam(name = "province", value = "所在省份", dataType = "String"),
            @ApiImplicitParam(name = "city", value = "所在城市", dataType = "String"),
            @ApiImplicitParam(name = "nature", value = "单位性质字典值", dataType = "String"),
            @ApiImplicitParam(name = "industry", value = "单位行业字典值", dataType = "String"),
            @ApiImplicitParam(name = "scale", value = "单位规模字典值", dataType = "String"),
    })
    @ApiResponses({
            @ApiResponse(code = 1, message = "查询成功（total：总数，省份：provinceList，性质：natureList，行业：industryList，规模：scaleList")
    })
    @GetMapping("/school/statistics/preach")
    public JsonResult countPreach(HttpServletRequest request) {
        PageParam<PreachListVO> pageParam = new PageParam<>(request);
        return preachService.countPreach(pageParam);
    }


    @PreAuthorize("hasAuthority('school:statistics:preach-cloud')")
    @OperLog(value = "空中宣讲会发布统计", desc = "统计查询")
    @ApiOperation(value = "空中宣讲会发布统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "applyTime", value = "举办时间开始时间~举办时间结束时间 yyyy-MM-dd~yyyy-MM-dd，例：2021-3-10~2021-3-30", dataType = "String"),
            @ApiImplicitParam(name = "title", value = "标题", dataType = "String"),
            @ApiImplicitParam(name = "companyName", value = "主办方", dataType = "String"),
            @ApiImplicitParam(name = "invalid", value = "是否取消（1：已取消 0：未取消）", dataType = "String"),
            @ApiImplicitParam(name = "state", value = "审核状态（0：待审核 1：审核通过 2：审核不通过）", dataType = "String"),

    })
    @ApiResponses({
            @ApiResponse(code = 1, message = "查询成功（total：总数，省份：provinceList，性质：natureList，行业：industryList，规模：scaleList")
    })
    @GetMapping("/school/statistics/preach-cloud")
    public JsonResult countPreachCloud(HttpServletRequest request) {
        PageParam<PreachCloudListVO> pageParam = new PageParam<>(request);
        return preachCloudService.countPreachCloud(pageParam);
    }


    @PreAuthorize("hasAuthority('school:statistics:mutual')")
    @OperLog(value = "校内双选会发布统计", desc = "统计查询")
    @ApiOperation(value = "校内双选会发布统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "applyTime", value = "举办时间开始时间~举办时间结束时间 yyyy-MM-dd~yyyy-MM-dd，例：2021-3-10~2021-3-30", dataType = "String"),
            @ApiImplicitParam(name = "title", value = "标题", dataType = "String"),
            @ApiImplicitParam(name = "fieldName", value = "举办场地", dataType = "String"),
            @ApiImplicitParam(name = "companyName", value = "主办方", dataType = "String"),
            @ApiImplicitParam(name = "province", value = "所在省份", dataType = "String"),
            @ApiImplicitParam(name = "city", value = "所在城市", dataType = "String"),
            @ApiImplicitParam(name = "nature", value = "单位性质字典值", dataType = "String"),
            @ApiImplicitParam(name = "industry", value = "单位行业字典值", dataType = "String"),
            @ApiImplicitParam(name = "scale", value = "单位规模字典值", dataType = "String"),
    })
    @ApiResponses({
            @ApiResponse(code = 1, message = "查询成功（total：总数，totalCompany：单位总数，省份：provinceList，性质：natureList，行业：industryList，规模：scaleList")
    })
    @GetMapping("/school/statistics/mutual")
    public JsonResult countMutual(HttpServletRequest request) {
        PageParam<MutualApplyListVO> pageParam = new PageParam<>(request);
        return mutualApplyService.countMutual(pageParam);
    }

    @PreAuthorize("hasAuthority('school:statistics:push-msg')")
    @OperLog(value = "推荐信息统计", desc = "推荐信息统计")
    @ApiOperation(value = "推荐信息统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "applyTime", value = "开始时间~结束时间 yyyy-MM-dd~yyyy-MM-dd，例：2021-3-10~2021-3-30", dataType = "String"),
            @ApiImplicitParam(name = "collegeCode", value = "学院编号", dataType = "String"),
            @ApiImplicitParam(name = "type", value = "业务类型（1：招聘；2：宣讲会；3：空中宣讲会）", dataType = "String"),
    })
    @ApiResponses({
            @ApiResponse(code = 1, message = "查询成功（推荐总人次：pushCountTotal，推荐阅读总数：readTotal，推荐总发送简历数：resumeTotal，businessTotal：推荐信息总数，推荐信息单位总数：companyTotal，推荐信息接收学生总数：studentTotal，推荐信息职位总数：positionTotal，推荐信息职位招聘总人数：positionRecruitTotal，省份：provinceList，性质：natureList，行业：industryList，规模：scaleList，学院统计：collegeList，专业统计：majorList，职位统计：positionList")
    })
    @GetMapping("/school/statistics/message")
    public JsonResult countMessage(HttpServletRequest request) throws IOException {
        PageParam<ElasticPushMsgFormVO> pageParam = new PageParam<>(request);

        // collegeUser true 学院用户
        User loginUser = getLoginUser();
        if (!StrUtil.isBlank(loginUser.getCollegeCode())) {
            College college = collegeService.getByCode(loginUser.getCollegeCode());
            pageParam.put(PushConstants.COLLEGE_CODE, loginUser.getCollegeCode());
            return pushMsgService.countMessage(pageParam).put("collegeUser", true).put("collegeName", college != null ? college.getName() : "");
        }

        return pushMsgService.countMessage(pageParam).put("collegeUser", false);
    }

    @PreAuthorize("hasAuthority('school:statistics:push-msg')")
    @ApiOperation("获取学院数据")
    @GetMapping("/school/statistics/get-college")
    public JsonResult getDictCollege() {
        List<College> collegeList = collegeService.listAll(null, "");
        return JsonResult.ok().setData(collegeList);
    }

    @ApiOperation("获取单位字典数据")
    @GetMapping("/school/statistics/get-dict")
    public JsonResult getDict() {
        return companyService.getStatisticsDict();
    }

    @PreAuthorize("hasAuthority('school:statistics:sign')")
    @OperLog(value = "签约统计", desc = "签约统计")
    @ApiOperation("签约统计")
    @GetMapping("/school/statistics/sign")
    public JsonResult listCollege(StudentSignStatistics studentSignStatistics) {
        List<College> collegeList = collegeService.listAll(null, "");
        List<Dict> signCategoryList = dictService.cacheList(DictConstants.TYPE_SIGN_CATEGORY);
        JsonResult jsonResult = studentSignService.signStatistics(studentSignStatistics);
        jsonResult.put("collegeList", collegeList);
        jsonResult.put("signCategoryList", signCategoryList);
        return jsonResult;
    }


    @PreAuthorize("hasAuthority('school:statistics:sign')")
    @OperLog(value = "所有学院签约统计", desc = "所有学院签约统计")
    @ApiOperation("所有学院签约统计")
    @GetMapping("/school/statistics/all-sign")
    public JsonResult allListCollege(StudentSignStatistics studentSignStatistics) {
        // 获取所有学院
        List<College> collegeList = collegeService.listAll(null, "");
        return studentSignService.allSignStatistics(studentSignStatistics, collegeList);
    }

    @PreAuthorize("hasAuthority('school:statistics:status')")
    @OperLog(value = "就业状态统计", desc = "就业状态统计")
    @ApiOperation("就业状态统计")
    @GetMapping("/school/statistics/status")
    public JsonResult status(Integer year, String colleges) {
        return statisticsService.status(year, colleges);
    }

    @PreAuthorize("hasAuthority('school:statistics:status')")
    @OperLog(value = "就业状态统计", desc = "导出", result = true)
    @ApiOperation(value = "导出")
    @GetMapping("/school/statistics/export")
    public void export(Integer year, String colleges, HttpServletResponse response) {
        statisticsService.exportStatus(year, colleges, response);
    }

    @PreAuthorize("hasAuthority('school:statistics:tend')")
    @OperLog(value = "就业状态统计", desc = "就业状态统计")
    @ApiOperation("就业状态统计")
    @GetMapping("/school/statistics/tend")
    public JsonResult tendStatus() {
        return statisticsService.statisticsTend();
    }

    @PreAuthorize("hasAuthority('school:statistics:status')")
    @OperLog(value = "就业状态统计", desc = "导出", result = true)
    @ApiOperation(value = "导出")
    @GetMapping("/school/statistics/tend/export")
    public void exportTend(HttpServletResponse response) {
        statisticsService.exportTend(response);
    }

    @PreAuthorize("hasAuthority('school:statistics:student')")
    @OperLog(value = "生源统计", desc = "生源统计")
    @ApiOperation("生源统计")
    @GetMapping("/school/statistics/student")
    public JsonResult status(String year) {
        return studentService.statisticsStudent(year);
    }

    @PreAuthorize("hasAuthority('school:statistics:student')")
    @OperLog(value = "精准匹配院统计", desc = "精准匹配院统计")
    @ApiOperation("精准匹配院统计")
    @GetMapping("/school/statistics/college-push")
    public JsonResult pushCollege(HttpServletRequest request) {
        PageParam<ElasticPushMsgFormVO> pageParam = new PageParam<>(request);
        return pushMsgService.statisticsStudentPushByCollege(pageParam);
    }

    @PreAuthorize("hasAuthority('school:statistics:alumni')")
    @OperLog(value = "毕业生网签供校友使用数据", desc = "毕业生网签供校友使用数据")
    @ApiOperation("毕业生网签供校友使用数据")
    @GetMapping("/school/statistics/alumni")
    public PageResult<StudentSignAlumniVO> alumni(HttpServletRequest request) {
        PageParam<StudentSign> pageParam = new PageParam<>(request);
        return studentSignService.listAlumniPage(pageParam);
    }

    @PreAuthorize("hasAuthority('school:statistics:sign-college')")
    @OperLog(value = "学院就业率统计", desc = "学院就业率统计最后时间")
    @ApiOperation("学院就业率统计")
    @GetMapping("/school/statistics/sign-college-time")
    public JsonResult signCollegeTime(Integer year, String xl) {
        List<StudentSignRecord> list = studentSignRecordService.list(new LambdaQueryWrapper<StudentSignRecord>()
                .eq(StudentSignRecord::getYear, year)
                .eq(StudentSignRecord::getXl, xl)
                .orderByDesc(StudentSignRecord::getCreateTime)
                .last(" LIMIT 1")
        );
        Date date = null;
        if (!CollectionUtil.isEmpty(list)) {
            date = list.get(0).getCreateTime();
        }

        return JsonResult.ok().setData(date);
    }

    @PreAuthorize("hasAuthority('school:statistics:sign-college')")
    @OperLog(value = "学院就业率统计", desc = "学院就业率统计")
    @ApiOperation("学院就业率统计")
    @GetMapping("/school/statistics/sign-college")
    public JsonResult signCollege(Integer year, String xl, Date createTime) {
        List<StudentSignRecord> studentSignRecordList =
                studentSignRecordService.getStudentSignRateRecord(year, xl, createTime);
        return JsonResult.ok().setData(studentSignRecordList);
    }

    @PreAuthorize("hasAuthority('school:statistics:sign-college')")
    @OperLog(value = "学院就业率实时统计", desc = "学院就业率实时统计")
    @ApiOperation("学院就业率实时统计")
    @GetMapping("/school/realtime/statistics/sign-college")
    public JsonResult realTimeSignCollege(Integer year, String xl, Date createTime) {
        studentSignRecordService.recordStudentSignRateNoDelete(year, xl,createTime);
        List<StudentSignRecord> studentSignRecordList =
                studentSignRecordService.getStudentSignRateRecord(year, xl, createTime);
        return JsonResult.ok().setData(studentSignRecordList);
    }

    @PreAuthorize("hasAuthority('school:statistics:sign-college')")
    @OperLog(value = "学院就业率统计", desc = "更新学院就业率统计")
    @ApiOperation("学院就业率统计")
    @GetMapping("/school/statistics/sign-college-update")
    public JsonResult signCollegeUpdate(Integer year) {
        String[] state = {"0", "1", "2", "3", "4"};
        for (String xl : state) {
            studentSignRecordService.recordStudentSignRate(year, xl, null, null);
        }
        return JsonResult.ok();
    }

    @PreAuthorize("hasAuthority('school:statistics:sign-major')")
    @OperLog(value = "专业就业率统计", desc = "专业就业率统计")
    @ApiOperation("专业就业率统计")
    @GetMapping("/school/statistics/sign-major")
    public JsonResult signMajor(Integer year, String xl, Date createTime) {

        List<StudentSignMajorRecord> studentSignMajorRecordList =
                studentSignMajorRecordService.getStudentMajorSignRateRecord(year, xl, createTime);

        return JsonResult.ok().setData(studentSignMajorRecordList);
    }

    @PreAuthorize("hasAuthority('school:statistics:sign-mz')")
    @OperLog(value = "民族就业率统计", desc = "民族就业率统计")
    @ApiOperation("民族就业率统计")
    @GetMapping("/school/statistics/sign-mz")
    public JsonResult signMz(Integer year, String xl, String tks) {
        List<StudentSignStatisticsCollegeVO> studentList = studentService.mzStudentCount(year, xl, tks);
        if (studentList.size() == 0) {
            return JsonResult.error("暂无数据");
        }

        List<StudentSignStatisticsCollegeVO> studentSignList = studentSignService.mzStudentSignCount(year, xl, tks);
        if (studentSignList.size() == 0) {
            return JsonResult.error("暂无数据");
        }

        // 结果集装载民族名称、民族人数
        // 结果集加入统计为0的民族
        for (StudentSignStatisticsCollegeVO student : studentList) {
            boolean b = false;
            for (StudentSignStatisticsCollegeVO sign : studentSignList) {
                if (student.getMz().equals(sign.getMz())) {
                    sign.setMz(student.getMz());
                    sign.setStudentCount(student.getStudentCount());
                    b = true;
                }
            }
            if (!b) {
                studentSignList.add(new StudentSignStatisticsCollegeVO(student.getMz(), student.getStudentCount()));
            }
        }

        // 定向生算进签约率
        List<Student> dxList = studentService.list(new QueryWrapper<Student>()
                .select("COUNT(1) id, mz")
                .eq("year_id", year)
                .eq("pyfs", StudentConstants.PYFS_DX)
                .ne("mz", "01")
                .and("1".equals(xl), d -> d.eq("xl", "31").or().eq("xl", "25"))
                .eq("2".equals(xl), "xl", "11")
                .eq("3".equals(xl), "xl", "01")
                .and("4".equals(xl), d -> d.eq("xl", "11").or().eq("xl", "01"))
                .eq(!StrUtil.isBlank(tks), "tks", tks)
                .groupBy("mz")
        );
        for (StudentSignStatisticsCollegeVO sign : studentSignList) {
            for (Student student : dxList) {
                if (sign.getMz().equals(student.getMz())) {
                    sign.setStudentSignCount(sign.getStudentSignCount() + student.getId());
                    sign.setXyjyCount(sign.getXyjyCount() + student.getId());
                }
            }
        }

        // 合计参数
        String totalName = "合计";
        Integer totalStudent = 0;
        Integer totalStudentSign = 0;
        Integer totalXyjy = 0;
        Integer totalZzcy = 0;
        Integer totalLhjy = 0;
        Integer totalZyzy = 0;
        Integer totalSx = 0;
        Integer totalCgcj = 0;
        Integer totalDjy = 0;

        // 开始计算百分比
        String rate = "#.##%";
        for (StudentSignStatisticsCollegeVO item : studentSignList) {
            Integer studentCount = item.getStudentCount();
            Integer studentSignCount = item.getStudentSignCount();

            BigDecimal studentRateB = NumberUtil.div(studentSignCount, studentCount);
            String studentRate = NumberUtil.decimalFormat(rate, studentRateB);
            item.setStudentRate(studentRate);

            BigDecimal xyjyRateB = NumberUtil.div(item.getXyjyCount(), studentCount);
            String xyjyRate = NumberUtil.decimalFormat(rate, xyjyRateB);
            item.setXyjyRate(xyjyRate);

            BigDecimal zzcyRateB = NumberUtil.div(item.getZzcyCount(), studentCount);
            String zzcyRate = NumberUtil.decimalFormat(rate, zzcyRateB);
            item.setZzcyRate(zzcyRate);

            BigDecimal lhjyRateB = NumberUtil.div(item.getLhjyCount(), studentCount);
            String lhjyRate = NumberUtil.decimalFormat(rate, lhjyRateB);
            item.setLhjyRate(lhjyRate);

            BigDecimal zyzyRateB = NumberUtil.div(item.getZyzyCount(), studentCount);
            String zyzyRate = NumberUtil.decimalFormat(rate, zyzyRateB);
            item.setZyzyRate(zyzyRate);

            BigDecimal sxRateB = NumberUtil.div(item.getSxCount(), studentCount);
            String sxRate = NumberUtil.decimalFormat(rate, sxRateB);
            item.setSxRate(sxRate);

            BigDecimal cgcjRateB = NumberUtil.div(item.getCgcjCount(), studentCount);
            String cgcjRate = NumberUtil.decimalFormat(rate, cgcjRateB);
            item.setCgcjRate(cgcjRate);

            Integer djyCount = studentCount - studentSignCount;
            BigDecimal djyRateB = NumberUtil.div(djyCount, studentCount);
            String djyRate = NumberUtil.decimalFormat(rate, djyRateB);
            item.setDjyRate(djyRate);
            item.setDjyCount(djyCount);

            totalStudent += studentCount;
            totalStudentSign += studentSignCount;
            totalXyjy += item.getXyjyCount();
            totalZzcy += item.getZzcyCount();
            totalLhjy += item.getLhjyCount();
            totalZyzy += item.getZyzyCount();
            totalSx += item.getSxCount();
            totalCgcj += item.getCgcjCount();
            totalDjy += item.getDjyCount();
        }

        // 民族字典转换
        List<Dict> mz = dictService.listAll(DictConstants.TYPE_MZ, null);
        studentSignList.forEach(item -> {
            for (Dict dict : mz) {
                if (item.getMz().equals(dict.getValue())) {
                    item.setMz(dict.getLabel());
                }
            }
        });

        // 合计
        StudentSignStatisticsCollegeVO total = new StudentSignStatisticsCollegeVO();
        total.setMz(totalName);
        total.setStudentCount(totalStudent);
        total.setStudentSignCount(totalStudentSign);

        BigDecimal studentRateB = NumberUtil.div(totalStudentSign, totalStudent);
        String studentRate = NumberUtil.decimalFormat(rate, studentRateB);
        total.setStudentRate(studentRate);

        BigDecimal xyjyRateB = NumberUtil.div(totalXyjy, totalStudent);
        String xyjyRate = NumberUtil.decimalFormat(rate, xyjyRateB);
        total.setXyjyRate(xyjyRate);
        total.setXyjyCount(totalXyjy);

        BigDecimal zzcyRateB = NumberUtil.div(totalZzcy, totalStudent);
        String zzcyRate = NumberUtil.decimalFormat(rate, zzcyRateB);
        total.setZzcyRate(zzcyRate);
        total.setZzcyCount(totalZzcy);

        BigDecimal lhjyRateB = NumberUtil.div(totalLhjy, totalStudent);
        String lhjyRate = NumberUtil.decimalFormat(rate, lhjyRateB);
        total.setLhjyRate(lhjyRate);
        total.setLhjyCount(totalLhjy);

        BigDecimal zyzyRateB = NumberUtil.div(totalZyzy, totalStudent);
        String zyzyRate = NumberUtil.decimalFormat(rate, zyzyRateB);
        total.setZyzyRate(zyzyRate);
        total.setZyzyCount(totalZyzy);

        BigDecimal sxRateB = NumberUtil.div(totalSx, totalStudent);
        String sxRate = NumberUtil.decimalFormat(rate, sxRateB);
        total.setSxRate(sxRate);
        total.setSxCount(totalSx);

        BigDecimal cgcjRateB = NumberUtil.div(totalCgcj, totalStudent);
        String cgcjRate = NumberUtil.decimalFormat(rate, cgcjRateB);
        total.setCgcjRate(cgcjRate);
        total.setCgcjCount(totalCgcj);

        BigDecimal djyRateB = NumberUtil.div(totalDjy, totalStudent);
        String djyRate = NumberUtil.decimalFormat(rate, djyRateB);
        total.setDjyRate(djyRate);
        total.setDjyCount(totalDjy);

        studentSignList.add(0, total);

        return JsonResult.ok().setData(studentSignList);
    }

    @PreAuthorize("hasAuthority('school:statistics:sign-college-rate')")
    @OperLog(value = "学院目标就业率统计", desc = "学院目标就业率统计")
    @ApiOperation("学院目标就业率统计")
    @GetMapping("/school/statistics/sign-college-rate")
    public JsonResult signCollegeRate(Integer year, String xl, String tks) {
        List<StudentSignStatisticsCollegeVO> studentList = studentService.collegeStudentCount(year, xl, tks);
        if (studentList.size() == 0) {
            return JsonResult.error("暂无数据");
        }

        List<StudentSignStatisticsCollegeVO> studentSignList = studentSignService.collegeStudentSignCount(year, xl, tks, null, null);
        if (studentSignList.size() == 0) {
            return JsonResult.error("暂无数据");
        }

        // 结果集装载学院名称、学院人数
        // 结果集加入统计为0的学院
        for (StudentSignStatisticsCollegeVO student : studentList) {
            boolean b = false;
            for (StudentSignStatisticsCollegeVO sign : studentSignList) {
                if (!StrUtil.isBlank(student.getCollegeCode()) && student.getCollegeCode().equals(sign.getCollegeCode())) {
                    sign.setCollegeName(student.getCollegeName());
                    sign.setCollegeRate5(student.getCollegeRate5());
                    sign.setCollegeRate8(student.getCollegeRate8());
                    sign.setStudentCount(student.getStudentCount());
                    b = true;
                }
            }
            if (!b) {
                studentSignList.add(new StudentSignStatisticsCollegeVO(student.getCollegeName(), student.getCollegeCode(), student.getStudentCount()));
            }
        }

        // 定向生算进签约率
        List<Student> dxList = studentService.list(new QueryWrapper<Student>()
                .select("COUNT(1) id, college_code")
                .eq("year_id", year)
                .eq("pyfs", StudentConstants.PYFS_DX)
                .and("1".equals(xl), d -> d.eq("xl", "31").or().eq("xl", "25"))
                .eq("2".equals(xl), "xl", "11")
                .eq("3".equals(xl), "xl", "01")
                .and("4".equals(xl), d -> d.eq("xl", "11").or().eq("xl", "01"))
                .eq(!StrUtil.isBlank(tks), "tks", tks)
                .groupBy("college_code")
        );
        for (StudentSignStatisticsCollegeVO sign : studentSignList) {
            for (Student student : dxList) {
                if (!StrUtil.isBlank(sign.getCollegeCode()) && sign.getCollegeCode().equals(student.getCollegeCode())) {
                    sign.setStudentSignCount(sign.getStudentSignCount() + student.getId());
                    sign.setXyjyCount(sign.getXyjyCount() + student.getId());
                }
            }
        }

        for (StudentSignStatisticsCollegeVO item : studentSignList) {
            Integer studentCount = item.getStudentCount();
            Integer studentSignCount = item.getStudentSignCount();

            BigDecimal studentRate = NumberUtil.div(studentSignCount, studentCount);
            studentRate = studentRate.multiply(new BigDecimal(100));
            studentRate = studentRate.setScale(2, BigDecimal.ROUND_HALF_UP);
            item.setCurrent(studentRate);

            if (item.getCollegeRate5() == null) {
                item.setCollegeRate5(0);
            }
            BigDecimal five = new BigDecimal(item.getCollegeRate5());
            BigDecimal fiveRate = five.subtract(studentRate);
            item.setCompare5(fiveRate);

            if (item.getCollegeRate8() == null) {
                item.setCollegeRate8(0);
            }
            BigDecimal eight = new BigDecimal(item.getCollegeRate8() == null ? 0 : item.getCollegeRate8());
            BigDecimal eightRate = eight.subtract(studentRate);
            item.setCompare8(eightRate);
        }

        return JsonResult.ok().setData(studentSignList);
    }

    @ApiOperation("获取树形学院数据")
    @GetMapping("/school/statistics/tree-college/{year}")
    public JsonResult treeCollege(@PathVariable("year") Integer year) {
        List<College> collegeList = collegeService.listAll(null, "");

        College bk = new College();
        bk.setParentCode("0");
        bk.setCode("bk");
        bk.setName("本科");


        College yjs = new College();
        yjs.setParentCode("0");
        yjs.setCode("yjs");
        yjs.setName("研究生");

        for (College college : collegeList) {
            if (1 == college.getXl()) {
                college.setParentCode("bk");
            }
            if (2 == college.getXl()) {
                college.setParentCode("yjs");
            }
        }

        collegeList.add(bk);
        collegeList.add(yjs);

        List<Student> studentList = studentService.list(new LambdaQueryWrapper<Student>()
                .select(Student::getCollegeCode, Student::getBjhm).eq(Student::getYearId, year)
                .groupBy(Student::getBjhm));

        for (Student student : studentList) {
            if (!StrUtil.isBlank(student.getBjhm())) {
                College college = new College();
                college.setParentCode(student.getCollegeCode());
                college.setCode("b_" + student.getBjhm());
                college.setName(student.getBjhm());
                collegeList.add(college);
            }
        }

        return JsonResult.ok().setData(collegeList);
    }

    @PreAuthorize("hasAuthority('school:statistics:employment-process')")
    @ApiOperation("学院后期促进就业过程管理统计")
    @GetMapping("/school/statistics/employment-process")
    public JsonResult employmentProcess(String startTime, String endTime) {
        Date s = new Date();
        if (!StrUtil.isBlank(startTime)) {
            DateTime parse = DateUtil.parse(startTime);
            s = parse.toJdkDate();
        }

        Date e = new Date();
        if (!StrUtil.isBlank(endTime)) {
            DateTime parse = DateUtil.parse(endTime);
            e = parse.toJdkDate();
        }

        Date startOfWeek = DateUtil.beginOfWeek(s);
        Date endOfWeek = DateUtil.endOfWeek(e);
        String startStr = DateUtil.format(startOfWeek, DatePattern.NORM_DATETIME_PATTERN);
        String endStr = DateUtil.format(endOfWeek, DatePattern.NORM_DATETIME_PATTERN);

        List<EmploymentProcess> employmentProcessList = employmentProcessService.statistics(startStr, endStr);
        if (employmentProcessList == null) {
            return JsonResult.ok().setData(new ArrayList<>());
        }

        // 赋值模板
        List<EmploymentProcess> templateList = employmentProcessService.listTemplate();
        List<EmploymentProcessStatisticsVO> resultList = new ArrayList<>();
        for (EmploymentProcess template : templateList) {
            EmploymentProcessStatisticsVO item = new EmploymentProcessStatisticsVO();
            BeanUtil.copyProperties(template, item);
            resultList.add(item);
        }

        // 赋值查询结果
        for (EmploymentProcessStatisticsVO result : resultList) {
            for (EmploymentProcess item : employmentProcessList) {
                if (!result.getMatter().equals(item.getMatter())) {
                    continue;
                }

                int number = item.getNumber() != null ? item.getNumber() : 0;
                switch (item.getCollegeName()) {
                    case "马克思主义学院":
                        result.setMkszyxyJi(number);
                        break;
                    case "哲学院研":
                        result.setZxyYan(number);
                        break;
                    case "哲学院":
                        result.setZxyBen(number);
                        break;
                    case "经济学院研":
                        result.setJjxyYan(number);
                        break;
                    case "经济学院":
                        result.setJjxyBen(number);
                        break;
                    case "财政税务学院研":
                        result.setCzswxyYan(number);
                        break;
                    case "财政税务学院":
                        result.setCzswxyBen(number);
                        break;
                    case "金融学院研":
                        result.setJrxyYan(number);
                        break;
                    case "金融学院":
                        result.setJrxyBen(number);
                        break;
                    case "法学院研":
                        result.setFxyYan(number);
                        break;
                    case "法学院":
                        result.setFxyBen(number);
                        break;
                    case "刑事司法学院研":
                        result.setXssfxyYan(number);
                        break;
                    case "刑事司法学院":
                        result.setXssfxyBen(number);
                        break;
                    case "外国语学院研":
                        result.setWgyxyYan(number);
                        break;
                    case "外国语学院":
                        result.setWgyxyBen(number);
                        break;
                    case "新闻与文化传播学院研":
                        result.setXwywhcbxyYan(number);
                        break;
                    case "新闻与文化传播学院":
                        result.setXwywhcbxyBen(number);
                        break;
                    case "工商管理学院研":
                        result.setGsglxyYan(number);
                        break;
                    case "工商管理学院":
                        result.setGsglxyBen(number);
                        break;
                    case "会计学院研":
                        result.setKjxyYan(number);
                        break;
                    case "会计学院":
                        result.setKjxyBen(number);
                        break;
                    case "公共管理学院研":
                        result.setGgglxyYan(number);
                        break;
                    case "公共管理学院":
                        result.setGgglxyBen(number);
                        break;
                    case "统计与数学学院研":
                        result.setTjysxxyYan(number);
                        break;
                    case "统计与数学学院":
                        result.setTjysxxyBen(number);
                        break;
                    case "信息与安全工程学院研":
                        result.setXxyaqgcxyYan(number);
                        break;
                    case "信息与安全工程学院":
                        result.setXxyaqgcxyBen(number);
                        break;
                    case "文澜学院研":
                        result.setWlxyYan(number);
                        break;
                    case "文澜学院":
                        result.setWlxyBen(number);
                        break;
                    case "法硕中心":
                        result.setFszxJi(number);
                        break;
                    case "知识产权学院":
                        result.setZscqxyJi(number);
                        break;
                    case "中韩新媒体学院":
                        result.setZhxmtxyJi(number);
                        break;
                }
            }
        }

        // 计算各院小计 和 行总计
        for (EmploymentProcessStatisticsVO result : resultList) {
            result.setZxyJi(result.getZxyBen() + result.getZxyYan());
            result.setJjxyJi(result.getJjxyBen() + result.getJjxyYan());
            result.setCzswxyJi(result.getCzswxyBen() + result.getCzswxyYan());
            result.setJrxyJi(result.getJrxyBen() + result.getJrxyYan());
            result.setFxyJi(result.getFxyBen() + result.getFxyYan());
            result.setXssfxyJi(result.getXssfxyBen() + result.getXssfxyYan());
            result.setWgyxyJi(result.getWgyxyBen() + result.getWgyxyYan());
            result.setXwywhcbxyJi(result.getXwywhcbxyBen() + result.getXwywhcbxyYan());
            result.setGsglxyJi(result.getGsglxyBen() + result.getGsglxyYan());
            result.setKjxyJi(result.getKjxyBen() + result.getKjxyYan());
            result.setGgglxyJi(result.getGgglxyBen() + result.getGgglxyYan());
            result.setTjysxxyJi(result.getTjysxxyBen() + result.getTjysxxyYan());
            result.setXxyaqgcxyJi(result.getXxyaqgcxyBen() + result.getXxyaqgcxyYan());
            result.setWlxyJi(result.getWlxyBen() + result.getWlxyYan());

            int total = result.getMkszyxyJi() + result.getFszxJi() + result.getZscqxyJi() + result.getZhxmtxyJi() +
                    result.getZxyJi() + result.getJjxyJi() + result.getCzswxyJi() + result.getJrxyJi() + result.getFxyJi() + result.getXssfxyJi() +
                    result.getWgyxyJi() + result.getXwywhcbxyJi() + result.getGsglxyJi() + result.getKjxyJi() + result.getGgglxyJi()
                    + result.getTjysxxyJi() + result.getXxyaqgcxyJi() + result.getWlxyJi();
            result.setTotal(total);
        }


        // 当前日期范围显示
        String start = DateUtil.format(startOfWeek, DatePattern.NORM_DATE_PATTERN);
        String end = DateUtil.format(endOfWeek, DatePattern.NORM_DATE_PATTERN);

        return JsonResult.ok().setData(resultList).put("range", start + "~" + end);
    }


    @PreAuthorize("hasAuthority('school:statistics:sign')")
    @ApiOperation("大屏统计-就业率")
    @GetMapping("/school/statistics/employ-rate")
    public JsonResult employRateStatistics(Integer year) {

        // 用来查询的时间
        Date date;

        // 如果是查询的本年
        if (DateUtil.today().contains(year.toString())) {
            // 获取当天18点的时间
            DateTime todaySixPM = DateUtil.parse(DateUtil.today() + " 18:00:00");

            // 判断当前是不是过了18点，如果过了18点就查当天的，如果没有就查前一天的
            if (DateUtil.date().before(todaySixPM)) {
                date = DateUtil.yesterday();
            } else {
                date = DateUtil.date();
            }
        } else {
            // 如果查询的不是本年就将date设定为year的最后一天
            date = DateUtil.parse(year + "-12-31");
        }

        Map<String, Object> result = new HashMap<>();

        // 查询本科就业率
        List<StudentSignRecord> bksSignRate =
                studentSignRecordService.getStudentSignRateRecord(year, "1", date);
        result.put("bksSignRate", bksSignRate);

        // 研究生
        List<StudentSignRecord> yjsSignRate =
                studentSignRecordService.getStudentSignRateRecord(year, "4", date);
        result.put("yjsSignRate", yjsSignRate);

        // 各学院
        List<StudentSignRecord> collegsSignRate =
                studentSignRecordService.getStudentSignRateRecord(year, "0", date);
        result.put("collegsSignRate", collegsSignRate);

        return JsonResult.ok().setData(result);
    }

    @PreAuthorize("hasAuthority('school:statistics:sign')")
    @ApiOperation("大屏统计-就业率折线图")
    @GetMapping("/school/statistics/employ-rate-zxt")
    public JsonResult employRateZxtStatistics(Integer year) {
        Map<String, Object> result = new HashMap<>();

        result.put("bksjyzxt", getStudentSignRateZxtStatistics(year, "1"));
        result.put("yjsjyzxt", getStudentSignRateZxtStatistics(year, "4"));

        return JsonResult.ok().setData(result);
    }


    /**
     * 获取折线图
     *
     * @param year
     * @param studentType
     * @return
     */
    private Map<String, Object> getStudentSignRateZxtStatistics(Integer year, String studentType) {
        Map<String, Object> result = new HashMap<>();

        for (int i = 2; i >= 0; i--) {
            Integer targetYear = year - i;
            List<StudentSignRecord> yearList = new ArrayList<>();
            for (int j = 0; j < quarterEndDateArr.length; j++) {
                if (DateUtil.today().contains(targetYear.toString())) {
                    if (DateUtil.quarter(DateUtil.date()) < j + 1) {
                        break;
                    }
                }
                DateTime date = DateUtil.parse(targetYear + quarterEndDateArr[j]);
                yearList.addAll(studentSignRecordService.getStudentSignRateRecord(targetYear, studentType, date));
            }
            result.put(targetYear.toString(), yearList);
        }

        return result;
    }

}
